import re
import time
import json
import requests

now = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
url = "https://shanghaicity.openservice.kankanews.com/public/tour/filterinfo2"
headers={
    'Content-type': 'application/json',
    'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 7_1_2 like Mac OS X) AppleWebKit/537.51.2 (KHTML, like Gecko) Mobile/11D257 MicroMessenger/6.0.1 NetType/WIFI'
}

try:
    response = requests.get(url, headers=headers)
    DisneyData = re.findall(rb'{"CODE":"102","NAME.*?}', response.content)
    if DisneyData:
        j = json.loads(DisneyData[0].decode())
    print('{0},{1},{2},{3}'.format(now, j['TIME'], j['R_TIME'], j['NUM']))

except Exception as e:
    pass
    # print(now,',', e)

